package org.example.B_100;

import java.util.Scanner;

/**
 * 响应报表时间
 */
public class CorrespondingMessageTime {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        //获取报文个数
        int c = sc.nextInt();

        //获取动态报文信息输入
        int[][] messages = new int[c][2];

        for (int i = 0; i < c; i++) {
            messages[i][0] = sc.nextInt();
            messages[i][1] = sc.nextInt();
        }

        //打印输出结果
        System.out.println(getResult(messages));
    }

    //功能实现逻辑
    public static int getResult(int[][] messages){
        //取每次对比中的最小值，所以预设一个最大值
        int ans = Integer.MAX_VALUE;

        //便利每条记录
        for (int[] message : messages){
            int respTime = message[0] + getMaxResonseTime(message[1]);
            ans = Math.min(ans,respTime);
        }
        //返回输出结果
        return ans;

    }

    public static int getMaxResonseTime(int m){
        if (m >= 128){
            StringBuilder bstr = new StringBuilder(Integer.toBinaryString(m));

            int exp = Integer.parseInt(bstr.substring(1,4),2);
            int mant = Integer.parseInt(bstr.substring(4),2);

            return (mant | 16) << (exp + 3);
        }else {
            return m;
        }
    }
}
